"""数据库系统常量定义模块

包含数据库管理系统的常量定义和异常导入
"""

# 导入所有异常类
from .error import (
    # 通用异常
    CacheFullException,
    FileExistsException,
    FileNotExistsException,
    FileCannotRWException,
    
    # 磁盘管理器异常
    BadLogFileException,
    MemTooSmallException,
    DataTooLargeException,
    DatabaseBusyException,
    
    # 事务管理器异常
    BadXIDFileException,
    
    # 版本管理器异常
    DeadlockException,
    ConcurrentUpdateException,
    NullEntryException,
    
    # 表管理器异常
    InvalidFieldException,
    FieldNotFoundException,
    FieldNotIndexedException,
    InvalidLogOpException,
    InvalidValuesException,
    DuplicatedTableException,
    TableNotFoundException,
    
    # 解析器异常
    InvalidCommandException,
    TableNoIndexException,
    
    # 传输层异常
    InvalidPkgDataException,
    
    # 服务器异常
    NestedTransactionException,
    NoTransactionException,
    
    # 启动器异常
    InvalidMemException,
)

# ============================================================================
# 数据库系统常量
# ============================================================================

# 页面大小常量
DEFAULT_PAGE_SIZE = 4096  # 4KB
MAX_PAGE_SIZE = 65536     # 64KB
MIN_PAGE_SIZE = 512       # 512B

# 缓冲池常量
DEFAULT_BUFFER_POOL_SIZE = 1024  # 默认缓冲池大小
MAX_BUFFER_POOL_SIZE = 10000     # 最大缓冲池大小
MIN_BUFFER_POOL_SIZE = 10        # 最小缓冲池大小

# 记录大小常量
MAX_RECORD_SIZE = 4000    # 最大记录大小
MIN_RECORD_SIZE = 1       # 最小记录大小

# 事务常量
MAX_TRANSACTION_ID = 2**63 - 1  # 最大事务ID
INVALID_TRANSACTION_ID = -1     # 无效事务ID

# 页面类型常量
PAGE_TYPE_HEADER = 0
PAGE_TYPE_INDEX = 1
PAGE_TYPE_DATA = 2
PAGE_TYPE_UNDO = 3
PAGE_TYPE_SYSTEM = 4

# 日志类型常量
LOG_TYPE_INSERT = 1
LOG_TYPE_UPDATE = 2
LOG_TYPE_DELETE = 3
LOG_TYPE_BEGIN = 4
LOG_TYPE_COMMIT = 5
LOG_TYPE_ABORT = 6

'''
Booter
'''
# 后缀
BOOTER_SUFFIX = ".bt"
# 临时后缀
BOOTER_TMP_SUFFIX = ".bt_tmp"